package com.rrjjg.app.core.beans;


import com.rrjjg.app.core.exception.MsgEnum;
import lombok.Data;

import java.io.Serializable;

@Data
public class ResultData<T> implements Serializable {

    private int code;

    private String msg;

    private T data;

    public ResultData() {
    }

    public ResultData(T data) {
        this.code = MsgEnum.OK.getCode();
        this.msg = MsgEnum.OK.getMgs();
        this.data = data;
    }

    public void fail(MsgEnum error) {
        this.code = error.getCode();
        this.msg = error.getMgs();
    }

    public void fail(String msg, int code) {
        this.code = code;
        this.msg = msg;
    }
}
